# 使用已有的Oracle JDK镜像作为基础镜像
FROM nginx:latest

ARG DIST_FILE="./dist/"
ARG NGINX_CONFIG="./nginx.conf"

RUN mkdir /app

# 设置容器内的工作目录
WORKDIR /app

# 将本地的JAR文件复制到容器的工作目录
COPY ${DIST_FILE} /app

COPY ${NGINX_CONFIG} /etc/nginx/nginx.conf.template

ENV PROXY_TARGET="default_target"

RUN sed -i "s|http://${PROXY_TARGET}/|http://${PROXY_TARGET}/|g" /etc/nginx/nginx.conf.template

EXPOSE 80

CMD ["sh", "-c", "envsubst '${PROXY_TARGET}' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf && exec nginx -g 'daemon off;'"]

